stage.set_background("halfcourt")
sprite = codesters.Sprite("player1")
sprite.go_to(-175, -150)
net = codesters.Sprite("basketballnet")
net.go_to(215, 175)
stage.set_gravity(10)
sprite.set_gravity_off()
def click(sprite):
ball = codesters.Sprite("basketball")
ball.go_to(-175, -125)
# add other actions...
sprite.event_click(click)
t = codesters.Teacher()
set_x_speeds = t.find_function("set_x_speed")
set_x_speeds_params = t.get_parameters_for_function("set_x_speed")
try:
tval1 = set_x_speeds[0][1]
tval2 = t.get_indent_at_line(set_x_speeds[0][0])
tval3 = int(set_x_speeds_params[0][0])
except:
tval1 = "DNE"
tval2 = "DNE"
tval3 = "DNE"
t1 = TestObjective()
t1.add_success("ball." in tval1, "Great job!")
t1.add_failure("sprite." in tval1, "Did you change the name in front of .set_x_speed() from sprite to ball?")
t1.add_failure(tval1 == "DNE", 'Did you drag in Set x Speed inside your click event?')
t2 = TestObjective()
t2.add_success(tval2 == 4, "Great job!")
t2.add_failure(tval2 == 0, 'Oops! Did you forget to indent your .set_x_speed() command?')
t2.add_failure(tval2 > 4, 'Oops! Did you indent your .set_x_speed() command too many times?')
t2.add_failure(tval2 == "DNE", 'Did you drag in Set x Speed inside your click event?')
t3 = TestObjective()
t3.add_success(tval3 == 10, "Great job!")
t3.add_failure(tval3 == 5, "Did you change the integer in your .set_x_speed() command?")
t3.add_failure(tval3 == "DNE", 'Did you drag in Set x Speed inside your click event?')
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
提交作品
-
下个活动
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)